package view;

import javax.swing.*;
import java.awt.*;

/***
 * Author: Mr.Zhao, Time: 2018/5/24/10:57
 * Description: 用于在游戏对战过程中进行聊天
 */
public class ChatPanel extends JPanel {
    private JTextField textField = null;
    private JButton btn_send = null;
    private ChessBoard chessBoard = null;

    private JList<String> jList = null;

    public ChatPanel() {
        chessBoard = ChessBoard.getInstance();
        jList = new JList<>();
        Font font = new Font("宋体", Font.PLAIN, chessBoard.getCellHeight() / 6);
        jList.setFont(font);
        jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        JScrollPane scrollPane = null;
        scrollPane = new JScrollPane(jList);

        JPanel sendMsgPanel = new JPanel(new BorderLayout());
        textField = new JTextField();
        btn_send = new JButton("发送消息");
        sendMsgPanel.add(textField, BorderLayout.CENTER);
        sendMsgPanel.add(btn_send, BorderLayout.EAST);

        this.setLayout(new BorderLayout());
        this.add(scrollPane, BorderLayout.CENTER);
        this.add(sendMsgPanel, BorderLayout.SOUTH);
        this.setSize((int) (chessBoard.getWidth() / 2.6),
                chessBoard.getHeight() - chessBoard.getMargin() * 2);
    }

    public JTextField getTextField() {
        return textField;
    }

    public JButton getBtn_send() {
        return btn_send;
    }

    public JList<String> getjList() {
        return jList;
    }
}
